<template>
	<view>
		<view class="webkit list">
			<view class="title">手机号</view>
			<input type="number" v-model="mobile" class="flex" placeholder="点击此处输入号码"/>
		</view>
		<button type="primary" style="background-image: linear-gradient(to bottom, rgb(243, 109, 31), rgb(252, 9, 9));margin-top: 20upx;" @click="submit">确认同步</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mobile:'',
				openid:''
			};
		},
		onLoad:function(){
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
				},
				fail: () => {
					uni.navigateTo({
						url: '../../login/login'
					});
				},
			});
			uni.hideLoading()
		},
		methods:{
			submit () {
				if (this.mobile == "") {
					uni.showToast({
						title: '请输入手机号',
						icon: "none"
					});
				}
				if(this.mobile.length != 11) {
					uni.showToast({
						title: '手机号不满足输入要求',
						icon: "none"
					});
					return
				}
				uni.request({
					url: 'http://hszj.hongshantang696.com//app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=account.tbdata&app=1',
					method: 'POST',
					data: {'openid':this.openid,'mobile':this.mobile},
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						if(res.data.error == 0) {
							uni.setStorage({
								key: 'openid',
								data: res.data.openid,
								success: (res) => {},
								fail: () => {}
							})
							uni.showToast({
								title: res.data.message,
									success() {
										setTimeout(()=>{
											uni.reLaunch({
												url: '../member'
											});
										},1500)
									}
							});
							
						} else {
							uni.showToast({
								title: res.data.message,
								icon:'none'
							});
						}
						
						
					},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style>.list{padding:16upx 24upx;background:#fff;position:relative;margin-top: 50upx;margin-bottom: 50upx;padding: 20upx 0;}.list:last-child:after{display:none;}.list:after{content:" ";position:absolute;left:20upx;right:20upx;bottom:-2upx;height:2upx;border-top:2upx solid #ebebeb;color:#D9D9D9;-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleY(0.5);-ms-transform:scaleY(0.5);transform:scaleY(0.5);}.list .title{width:150upx;line-height:50upx;color:#666;padding-left: 10upx;font-weight: 555;}.list .flex{line-height:50upx;color:#666;padding-left:24upx;}.inputright{width:200upx;height:52upx;}button.inputright{line-height:48upx;font-size:24upx;background:transparent;border:2upx solid #333;}</style>
